package com.henry.chatkit.weight.gatherimage

import android.graphics.Bitmap

class MultiImageData(var defaultImageResId: Int = 0, var imageUrls: List<Any>? = null) {

    val maxSize = 9

    //下载下来的图片地址
    var bitmapMap = mutableMapOf<Int, Bitmap>()

    fun putBitmap(bitmap: Bitmap?, position: Int) {
        synchronized(bitmapMap) {
            if (bitmap != null) {
                bitmapMap[position] = bitmap
            }
        }
    }

    fun getBitmap(position: Int): Bitmap? {
        synchronized(bitmapMap) { return bitmapMap[position] }
    }

    fun size(): Int {
        return if (null != imageUrls) {
            if (imageUrls!!.size > maxSize) maxSize else imageUrls!!.size
        } else {
            0
        }
    }

}